package top.mcwebsite.playandroid.gradle

import com.android.build.gradle.BaseExtension
import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.dependencies

fun Project.configureAndroid() {
    android {
        compileSdkVersion(Versions.compileSdk)

        defaultConfig {
            minSdk = Versions.minSdk
            targetSdk = Versions.targetSdk
        }


        compileOptions {
            sourceCompatibility = JavaVersion.VERSION_17
            targetCompatibility = JavaVersion.VERSION_17
            isCoreLibraryDesugaringEnabled = true
        }

        dependencies {
            // https://developer.android.com/studio/write/java8-support
            "coreLibraryDesugaring"(libs.findLibrary("tools.desugarjdklibs").get())
        }
    }
}

private fun Project.android(action: BaseExtension.() -> Unit) = extensions.configure(action)